home *** CD-ROM | disk | FTP | other *** search
/ Aminet 16 / Aminet 16 (1996)(GTI - Schatztruhe)[!][Dec 1996].iso / Aminet / dev / src / wangisrc.lha / wangi / z / GFindXXX / GFindXXX.c < prev    next >
C/C++ Source or Header  |  1996-09-16  |  16KB  |  697 lines

  1. /***************************************************************************
  2.  * GFindXXX.c
  3.  *
  4.  * GFindXXX, Copyright ©1995 Lee Kindness.
  5.  *
  6.  */
  7.  
  8. /* All our includes are in this file */
  9. #include "gst.c"
  10.  
  11. #include "GFindXXX_rev.h"
  12.  
  13. #define PROGNAME "GFindXXX"
  14.  
  15. /* Libraries used, don't auto open them SAS/C :) */
  16. struct Library *GotchaLibBase = NULL;
  17.  
  18. /* The differnet types of search fields */
  19. enum STypes { ST_NONE   = 0,
  20.               ST_SYSTEM = 1,
  21.               ST_SYSOP  = 2,
  22.               ST_PLACE  = 3,
  23.               ST_PHONE  = 4,
  24.               ST_ADR3D  = 5,
  25.               ST_ADR4D  = 6,
  26.               ST_ADR5D  = 7,
  27.               ST_FLAGS  = 8 };
  28.  
  29. struct stypes 
  30. {
  31.     STRPTR      text;
  32.     enum STypes type;
  33. };
  34.  
  35. /* Matches between the arguments supplied for STYPE and the enumeration */
  36. struct stypes texttype[] =
  37. {
  38.     {"system",    ST_SYSTEM},
  39.     {"sys",       ST_SYSTEM},
  40.     {"node",      ST_SYSTEM},
  41.     {"bbs",       ST_SYSTEM},
  42.     {"sysop",     ST_SYSOP},
  43.     {"owner",     ST_SYSOP},
  44.     {"place",     ST_PLACE},
  45.     {"city",      ST_PLACE},
  46.     {"location",  ST_PLACE},
  47.     {"loc",       ST_PLACE},
  48.     {"phone",     ST_PHONE},
  49.     {"telephone", ST_PHONE},
  50.     {"3d",        ST_ADR3D},
  51.     {"3",         ST_ADR3D},
  52.     {"4d",        ST_ADR4D},
  53.     {"4",         ST_ADR4D},
  54.     {"address",   ST_ADR4D},
  55.     {"addr",      ST_ADR4D},
  56.     {"adr",       ST_ADR4D},
  57.     {"5d",        ST_ADR5D},
  58.     {"5",         ST_ADR5D},
  59.     {"domain",    ST_ADR5D},
  60.     {"flags",     ST_FLAGS},
  61.     {"flag",      ST_FLAGS},
  62.     {NULL,        ST_NONE}
  63. };
  64.  
  65. LONG NLSearch(struct gl_context *nl, STRPTR pat, STRPTR npat, enum STypes stype,
  66.               BOOL full, BOOL points, BOOL cutdash, BOOL verbatim, STRPTR lformat);
  67.  
  68. const char *vtag = VERSTAG;
  69.  
  70.  
  71. /***************************************************************************
  72.  * SPrintf() -- Equiv. to sprintf().
  73.  */
  74.  
  75. void SPrintf(char *buffer, char *format, ...)
  76. {
  77.     RawDoFmt(format, (APTR)(&format+1), (void (*))"\x16\xC0\x4E\x75", buffer);
  78. }
  79.  
  80.  
  81. /***************************************************************************
  82.  * LFormat() -- Print out node details, when LFORMAT is selected.
  83.  */
  84.  
  85. /* Character format indicators for the LFORMAT option */
  86. #define SPEC        '%'
  87. #define S_ADDRESS3D '3'
  88. #define S_ADDRESS4D '4'
  89. #define S_ADDRESS5D '5'
  90. #define S_ADDRESS   'A'
  91. #define S_ALERT     'a'
  92. #define S_BAUD      'B'
  93. #define S_BSPACE    'b'
  94. #define S_STAR      'C'
  95. #define S_COST      'c'
  96. #define S_NODE4     'D'
  97. #define S_DOMAIN    'd'
  98. /* #define S_       'E' */
  99. #define S_NET       'e'
  100. #define S_FIRSTNAME 'F'
  101. #define S_FLAGS     'f'
  102. /* #define S_       'G' */
  103. #define S_GATE      'g'
  104. /* #define S_       'H' */
  105. #define S_HUB       'h'
  106. /* #define S_       'I' */
  107. #define S_TIME      'i'
  108. /* #define S_       'J' */
  109. /* #define S_       'j' */
  110. /* #define S_       'K' */
  111. /* #define S_       'k' */
  112. #define S_NLLINE    'L'
  113. #define S_LOCATION  'l'
  114. #define S_MAILONLY  'M'
  115. #define S_BBSNUM    'm'
  116. #define S_NODE      'N'
  117. #define S_NL        'n'
  118. #define S_BVPHONE   'O'
  119. #define S_VPHONE    'o'
  120. #define S_PHONE     'P'
  121. #define S_POINT     'p'
  122. /* #define S_       'Q' */
  123. #define S_DQUOTE    'q'
  124. #define S_REGION    'R'
  125. #define S_RETURN    'r'
  126. #define S_SYSTEM    'S'
  127. #define S_SYSOP     's'
  128. #define S_TYPE      'T'
  129. #define S_TAB       't'
  130. /* #define S_       'U' */
  131. #define S_ADDRESSA  'u'
  132. /* #define S_       'V' */
  133. #define S_VTAB      'v'
  134. /* #define S_       'W' */
  135. #define S_PASSWORD  'w'
  136. /* #define S_       'X' */
  137. #define S_SYSOPE    'x'
  138. /* #define S_       'Y' */
  139. /* #define S_       'y' */
  140. /* #define S_       'Z' */
  141. #define S_ZONE      'z'
  142.  
  143. #define FT_SHORT "%u %S, %l, %s, %P"
  144. #define FT_FULL  "Node %A, \"%S\" is in %l\n"    \
  145.                  "System is listed as %T\n"        \
  146.                  "Operated by %s\n"                        \
  147.                  "Region %R, Hub %h\n"                \
  148.                  "Phone %P, Cost %c\n"                \
  149.                  "Flags %f\n"                                    \
  150.                  "Password %w\n"
  151.  
  152. #define STATE_NONE 0
  153. #define STATE_SPEC 1
  154.  
  155. void LFormat(struct gl_nodeinfo *nd, STRPTR format, BOOL verbatim)
  156. {
  157.     STRPTR s, s2;
  158.     LONG state = STATE_NONE, num;
  159.     BPTR fh = Output();
  160.     
  161.     for( s = format; *s != '\000'; ++s )
  162.     {
  163.         switch( state )
  164.         {
  165.             case STATE_NONE:
  166.                 if( *s == SPEC )
  167.                     state = STATE_SPEC;
  168.                 else
  169.                     FPutC(fh, *s);
  170.                 break;
  171.             case STATE_SPEC:
  172.                 switch( *s )
  173.                 {
  174.                     case SPEC:
  175.                         FPutC(fh, SPEC);
  176.                         break;
  177.                     case S_NL:
  178.                         FPutC(fh, '\n');
  179.                         break;
  180.                     case S_TAB:
  181.                         FPutC(fh, '\t');
  182.                         break;
  183.                     case S_RETURN:
  184.                         FPutC(fh, '\r');
  185.                         break;
  186.                     case S_VTAB:
  187.                         FPutC(fh, '\v');
  188.                         break;
  189.                     case S_DQUOTE:
  190.                         FPutC(fh, '\"');
  191.                         break;
  192.                     case S_ALERT:
  193.                         FPutC(fh, '\a');
  194.                         break;
  195.                     case S_BSPACE:
  196.                         FPutC(fh, '\b');
  197.                         break;
  198.                     case S_STAR:
  199.                         FPutC(fh, '*');
  200.                         break;
  201.                     case S_SYSTEM:
  202.                         FPuts(fh, nd->name);
  203.                         break;
  204.                     case S_ADDRESS3D:
  205.                         FPrintf(fh, "%ld:%ld/%ld", nd->zone, nd->net,
  206.                                nd->node);
  207.                         break;
  208.                     case S_ADDRESS4D:
  209.                         FPrintf(fh, "%ld:%ld/%ld.%ld", nd->zone, nd->net,
  210.                                nd->node, nd->point);
  211.                         break;
  212.                     case S_ADDRESS5D:
  213.                     case S_ADDRESS:
  214.                         FPrintf(fh, "%ld:%ld/%ld.%ld@%s", nd->zone, nd->net,
  215.                                nd->node, nd->point, nd->domain);
  216.                         break;
  217.                     case S_ADDRESSA:
  218.                         if( nd->point )
  219.                             FPrintf(fh, "%ld:%ld/%ld.%ld", nd->zone, nd->net,
  220.                                nd->node, nd->point);
  221.                         else
  222.                             FPrintf(fh, "%ld:%ld/%ld", nd->zone, nd->net,
  223.                                nd->node);
  224.                         break;
  225.                     case S_LOCATION:
  226.                         FPuts(fh, nd->location);
  227.                         break;
  228.                     case S_SYSOP:
  229.                         FPuts(fh, nd->sysop);
  230.                         break;
  231.                     case S_FIRSTNAME:
  232.                         for( s2 = nd->sysop;
  233.                              (*s2) && (*s2 != ' ');
  234.                              ++s2 )
  235.                             FPutC(fh, *s2);
  236.                         break;
  237.                     case S_SYSOPE:
  238.                     case S_GATE:
  239.                         for( s2 = nd->sysop; *s2 != '\0'; ++s2 )
  240.                             if( *s2 == ' ' )
  241.                                 FPutC(fh, '.');
  242.                             else
  243.                                 FPutC(fh, tolower(*s2));
  244.                         if( *s == S_SYSOPE )
  245.                             break;
  246.                         if( nd->point )
  247.                             FPrintf(fh, "@p%ld.f%ld.n%ld.z%ld", nd->point, nd->node,
  248.                                nd->net, nd->zone);
  249.                         else
  250.                             FPrintf(fh, "@f%ld.n%ld.z%ld", nd->node,
  251.                                nd->net, nd->zone);
  252.                         break;
  253.                     case S_TYPE:
  254.                         /* Gotchlib does not support this... implement by hand */
  255.                         if( !stricmp(nd->phone, "-Unpublished-") )
  256.                             FPuts(fh, "Pvt");
  257.                         else if( nd->point )
  258.                             FPuts(fh, "Point");
  259.                         else if( (nd->zone == nd->net) && (nd->node == 0) )
  260.                             FPuts(fh, "Zone");
  261.                         else if( (nd->region == nd->net) && (nd->node == 0) )
  262.                             FPuts(fh, "Region");
  263.                         else if( nd->node == 0 )
  264.                             FPuts(fh, "Host");
  265.                         else if( nd->hub == nd->node )
  266.                             FPuts(fh, "Hub");
  267.                         else
  268.                             FPuts(fh, "Node");
  269.                         break;
  270.                     case S_NLLINE:
  271.                         s2 = "";
  272.                         num = nd->node;
  273.                         if( !stricmp(nd->phone, "-Unpublished-") )
  274.                             s2 = "Pvt";
  275.                         else if( nd->point )
  276.                         {
  277.                             s2 = "Point";
  278.                             num = nd->point;
  279.                         }
  280.                         else if( (nd->zone == nd->net) && (nd->node == 0) )
  281.                         {
  282.                             s2 = "Zone";
  283.                             num = nd->zone;
  284.                         }
  285.                         else if( (nd->region == nd->net) && (nd->node == 0) )
  286.                         {
  287.                             s2 = "Region";
  288.                             num = nd->region;
  289.                         }
  290.                         else if( nd->node == 0 )
  291.                         {
  292.                             s2 = "Host";
  293.                             num = nd->net;
  294.                         }
  295.                         else if( nd->hub == nd->node )
  296.                             s2 = "Hub";
  297.                         FPrintf(fh, "%s,%ld,", s2, num);
  298.                         for( s2 = nd->name; *s2 != '\0'; ++s2 )
  299.                             if( *s2 == ' ' )
  300.                                 FPutC(fh, '_');
  301.                             else
  302.                                 FPutC(fh, *s2);
  303.                         FPutC(fh, ',');
  304.                         for( s2 = nd->location; *s2 != '\0'; ++s2 )
  305.                             if( *s2 == ' ' )
  306.                                 FPutC(fh, '_');
  307.                             else
  308.                                 FPutC(fh, *s2);
  309.                         FPutC(fh, ',');
  310.                         for( s2 = nd->sysop; *s2 != '\0'; ++s2 )
  311.                             if( *s2 == ' ' )
  312.                                 FPutC(fh, '_');
  313.                             else
  314.                                 FPutC(fh, *s2);
  315.                         FPrintf(fh, ",%s,%s,%s", nd->phone, nd->baud, nd->flags);
  316.                         break;
  317.                     case S_BBSNUM:
  318.                         if( strstr(nd->flags, "MO") )
  319.                         {
  320.                             FPuts(fh, "MAIL ONLY");
  321.                             break;
  322.                         }
  323.                         /* FALLTHRU!!! */
  324.                     case S_PHONE:
  325.                         if( verbatim )
  326.                             FPuts(fh, nd->phone);
  327.                         else
  328.                             FPuts(fh, nd->tphone);
  329.                         break;
  330.                     case S_MAILONLY:
  331.                         if( strstr(nd->flags, "MO") )
  332.                             FPuts(fh, "MAIL ONLY");
  333.                         break;
  334.                     case S_BVPHONE:
  335.                         if( strstr(nd->flags, "MO") )
  336.                         {
  337.                             FPuts(fh, "MAIL ONLY");
  338.                             break;
  339.                         }
  340.                         /* FALLTHRU!!! */
  341.                     case S_VPHONE:
  342.                         FPuts(fh, nd->phone);
  343.                         break;
  344.                     case S_BAUD:
  345.                         FPuts(fh, nd->baud);
  346.                         break;
  347.                     case S_COST:
  348.                         if(nd->cost != -1)
  349.                             FPrintf(fh, "%01ld.%02ld", nd->cost/100, nd->cost%100);
  350.                         else
  351.                             FPrintf(fh, "undialable");
  352.                         break;
  353.                     case S_FLAGS:
  354.                         FPuts(fh, nd->flags);
  355.                         break;
  356.                     case S_TIME:
  357.                         if( strstr(nd->flags, "CM") )
  358.                             FPuts(fh, "24hr");
  359.                         else
  360.                             if( s2 = strstr(nd->flags, "U,") )
  361.                                 if( s2 = strstr(s2, ",T") )
  362.                                 {
  363.                                     LONG on_min   = 0;
  364.                                     LONG off_min  = 0;
  365.                                     LONG on_hour  = (LONG)(s2[2] - 'A');
  366.                                     LONG off_hour = (LONG)(s2[3] - 'A');
  367.                                     if( on_hour > 23 )
  368.                                     {
  369.                                         on_hour -= (LONG)('a' - 'A');
  370.                                         on_min = 30;
  371.                                     }
  372.                                     if( off_hour > 23 )
  373.                                     {
  374.                                         off_hour -= (LONG)('a' - 'A');
  375.                                         off_min = 30;
  376.                                     }
  377.                                     FPrintf(fh,"%02ld:%02ld->%02ld:%02ld (UTC)", on_hour, on_min, off_hour, off_min);
  378.                                 } else
  379.                                     FPuts(fh, "ZMH only");
  380.                             else
  381.                                 FPuts(fh, "ZMH only");
  382.                         break;
  383.                     case S_PASSWORD:
  384.                         FPuts(fh, (STRPTR)nd->password[0] ? (STRPTR)nd->password : (STRPTR)"none");
  385.                         break;
  386.                     case S_ZONE:
  387.                         FPrintf(fh, "%ld", nd->zone);
  388.                         break;
  389.                     case S_NET:
  390.                         FPrintf(fh, "%ld", nd->net);
  391.                         break;
  392.                     case S_NODE:
  393.                         FPrintf(fh, "%ld", nd->node);
  394.                         break;
  395.                     case S_NODE4:
  396.                         FPrintf(fh, "%04ld", nd->node);
  397.                         break;
  398.                     case S_POINT:
  399.                         FPrintf(fh, "%ld", nd->point);
  400.                         break;
  401.                     case S_DOMAIN: /*DING*/
  402.                         FPuts(fh, nd->domain);
  403.                         break;
  404.                     case S_REGION:
  405.                         FPrintf(fh, "%ld", nd->region);
  406.                         break;
  407.                     case S_HUB:
  408.                         FPrintf(fh, "%ld", nd->hub);
  409.                         break;
  410.                 }
  411.                 state = STATE_NONE;
  412.                 break;
  413.         }    
  414.     }
  415.     FPutC(fh, '\n');
  416. }
  417.  
  418. /***************************************************************************
  419.  * PrintNode() -- Print out node details.
  420.  */
  421.  
  422. void PrintNode(struct gl_nodeinfo *nd, BOOL full, BOOL verbatim, STRPTR lformat)
  423. {
  424.     if( lformat )
  425.         LFormat(nd, lformat, verbatim);
  426.     else if( full )
  427.         LFormat(nd, FT_FULL, verbatim);
  428.     else
  429.         LFormat(nd, FT_SHORT, verbatim);
  430. }
  431.  
  432.  
  433. /***************************************************************************
  434.  * NLSearch() -- Called for each search...
  435.  */
  436.  
  437. LONG NLSearch(struct gl_context *nl, STRPTR pat, STRPTR npat, enum STypes stype,
  438.               BOOL full, BOOL points, BOOL cutdash, BOOL verbatim, STRPTR lformat)
  439. {
  440.     LONG ret = 0;
  441.     struct gl_address *ad;
  442.     struct gl_nodeinfo *nd = NULL;
  443.     struct gl_pattern *pt = NULL;
  444.     
  445.     if( (ad = AllocVec(sizeof(struct gl_address), MEMF_CLEAR)) &&
  446.         (nd = AllocVec(sizeof(struct gl_nodeinfo), MEMF_CLEAR)) &&
  447.         (pt = AllocVec(sizeof(struct gl_pattern), MEMF_CLEAR)) )
  448.     {
  449.         STRPTR s = NULL;
  450.         ULONG sig = 0;
  451.         #define ADRBUFF_LEN 100
  452.         char adrbuff[ADRBUFF_LEN];
  453.         
  454.         /* convert */
  455.         GL_XtractInfos(ad, npat);
  456.         
  457.         switch( stype )
  458.         {
  459.             case ST_SYSTEM:
  460.                 s = nd->name;
  461.                 break;
  462.             
  463.             case ST_SYSOP:
  464.                 s = nd->sysop;
  465.                 break;
  466.             
  467.             case ST_PLACE:
  468.                 s = nd->location;
  469.                 break;
  470.             
  471.             case ST_PHONE:
  472.                 if( !cutdash )
  473.                 {
  474.                     if( verbatim )
  475.                         s = nd->phone;
  476.                     else
  477.                         s = nd->tphone;
  478.                 } else
  479.                     s = (STRPTR)-1;
  480.                 break;
  481.             
  482.             case ST_ADR3D:
  483.             case ST_ADR4D:
  484.             case ST_ADR5D:
  485.                 s = (STRPTR)-2;
  486.                 break;                
  487.             
  488.             case ST_FLAGS:
  489.                 s = nd->flags;
  490.                 break;
  491.         }
  492.     
  493.         if( s && GL_FindNodeFirst(ad, nl, nd, pt) )
  494.             do
  495.             {
  496.                 if( !nd->point || (points && nd->point) )
  497.                 {
  498.                     STRPTR ss;
  499.                     
  500.                     if( s == (STRPTR)-1 )
  501.                     {
  502.                         STRPTR src;
  503.                         
  504.                         if( verbatim )
  505.                             src = nd->phone;
  506.                         else
  507.                             src = nd->tphone;
  508.                         
  509.                         /* Strip out dashes */
  510.                         if( ss = AllocVec(strlen(src)+1, MEMF_CLEAR) )
  511.                         {
  512.                             STRPTR s2, s3;
  513.                             s3 = ss;
  514.                             for( s2 = src ; *s2 != '\0'; s2++ )
  515.                             {
  516.                                 if( *s2 != '-' )
  517.                                 {
  518.                                     *s3 = *s2;
  519.                                     s3++;
  520.                                 }
  521.                             }    
  522.                         }
  523.                     } else if( s == (STRPTR)-2 )
  524.                     {
  525.                         ss = adrbuff;
  526.                         switch( stype )
  527.                         {
  528.                             case ST_ADR3D:
  529.                                 SPrintf(ss, "%ld:%ld/%ld", nd->zone, nd->net, nd->node);
  530.                                 break;
  531.                             case ST_ADR4D:
  532.                                 SPrintf(ss, "%ld:%ld/%ld.%ld", nd->zone, nd->net, nd->node, nd->point);
  533.                                 break;
  534.                             case ST_ADR5D:
  535.                                 SPrintf(ss, "%ld:%ld/%ld.%ld@%s", nd->zone, nd->net, nd->node, nd->point, nd->domain);
  536.                                 break;
  537.                             default:
  538.                                 ss = NULL;
  539.                         }
  540.                     } else
  541.                         ss = s;
  542.                     
  543.                     if( ss )
  544.                     {
  545.                         if( MatchPatternNoCase(pat, ss) )
  546.                         {
  547.                             ++ret;
  548.                             PrintNode(nd, full, verbatim, lformat);
  549.                         }
  550.                     }
  551.                     
  552.                     if( s == (STRPTR)-1 )
  553.                         FreeVec(ss);
  554.                 }
  555.             } while( (GL_FindNodeNext(ad, nl, nd, pt)) && (!(sig = CheckSignal(SIGBREAKF_CTRL_C))) );
  556.             if( sig )
  557.                 PrintFault(ERROR_BREAK, "# " PROGNAME);
  558.     }
  559.     if( pt )
  560.         FreeVec(pt);
  561.     if( nd )
  562.         FreeVec(nd);
  563.     if( ad )
  564.         FreeVec(ad);
  565.     
  566.     return ret;
  567. }
  568.  
  569.  
  570. /***************************************************************************
  571.  * main() --
  572.  */
  573. int main(int argc, char **argv)
  574. {
  575.     int ret = RETURN_FAIL;
  576.     
  577.     /* Open libraries */
  578.     if( (GotchaLibBase = OpenLibrary("gotcha.library", 1)) &&
  579.         (DOSBase->dl_lib.lib_Version >= 36) ) 
  580.     {
  581.         /* Parse arguments */
  582.         struct RDArgs *rda;
  583.         #define DEF_NODELIST "Nodelist:"
  584.         #define DEF_NPAT "*"
  585.         #define DEF_STYPE "system"
  586.         #define TEMPLATE "PATTERN/M/A,N=NPAT/K,S=STYPE/K,FULL/S,POINTS/S,VERBATIM/S,STRIPDASHES/S,QUIET=NOINFO/S,LFORMAT/K,NODELIST/K"
  587.         #define OPT_PATTERN 0
  588.         #define OPT_NPAT 1
  589.         #define OPT_STYPE 2
  590.         #define OPT_FULL 3
  591.         #define OPT_POINTS 4
  592.         #define OPT_VERBATIM 5
  593.         #define OPT_STRIPDASHES 6
  594.         #define OPT_NOINFO 7
  595.         #define OPT_LFORMAT 8
  596.         #define OPT_NODELIST 9
  597.         #define OPT_MAX 10
  598.         STRPTR args[OPT_MAX] = {0, DEF_NPAT, DEF_STYPE, 0, 0, 0, 0, 0, 0, DEF_NODELIST};
  599.  
  600.         if( rda = ReadArgs(TEMPLATE, (LONG *)&args, NULL) ) 
  601.         {
  602.             STRPTR s;
  603.             
  604.             struct gl_context *nl;
  605.  
  606.             /* Open nodelist */
  607.             if( nl = GL_OpenNL(args[OPT_NODELIST]) )
  608.             {
  609.                 STRPTR *pata;
  610.                 LONG n = 0;
  611.                 LONG matches = 0;
  612.                 enum STypes st = ST_NONE;
  613.                 struct stypes *mat;
  614.                 
  615.                 for( mat = texttype;
  616.                      (mat->text) && (st == ST_NONE);
  617.                      mat++ )
  618.                 {
  619.                     if( stricmp(args[OPT_STYPE], mat->text) == 0 )
  620.                         st = mat->type;
  621.                 }
  622.                 if( st == ST_NONE )
  623.                     st = ST_SYSTEM;
  624.                 
  625.                 pata = (void *) args[OPT_PATTERN];
  626.                 
  627.                 ret = RETURN_OK;
  628.                 
  629.                 while( (s = pata[n]) && !ret ) 
  630.                 {
  631.                     STRPTR pattern;
  632.                     /* Act on the pattern */
  633.                 
  634.                     /* Alloc buffer for tokenized widcard */
  635.                     if( pattern = AllocVec(strlen(s)*3, MEMF_CLEAR) )
  636.                     {
  637.                         /* Parse wildcard */
  638.                         if( ParsePatternNoCase(s, pattern, strlen(s)*3) != -1 )
  639.                         {
  640.                         
  641.                             LONG num;
  642.                             
  643.                             /* CallFunc! */
  644.                             
  645.                             if( (num = NLSearch(nl,
  646.                                                 pattern,
  647.                                                 args[OPT_NPAT],
  648.                                                 st,
  649.                                   (BOOL)args[OPT_FULL],
  650.                                   (BOOL)args[OPT_POINTS],
  651.                                   (BOOL)args[OPT_STRIPDASHES],
  652.                                   (BOOL)args[OPT_VERBATIM],
  653.                                   args[OPT_LFORMAT])) == -1 )
  654.                             {
  655.                                 if( !args[OPT_NOINFO] )
  656.                                     PrintFault(IoErr(), "# " PROGNAME);
  657.                                 ret = RETURN_FAIL;
  658.                             } else if( num == 0 )
  659.                             {
  660.                                 if( !args[OPT_NOINFO] )
  661.                                     Printf("# No matches for \"%s\"\n", s);
  662.                             }
  663.                             else
  664.                                 matches += num;
  665.  
  666.                         }
  667.                         FreeVec(pattern);
  668.                     }
  669.                     n++;
  670.                 }
  671.                 
  672.                 if( matches )
  673.                 {
  674.                     if( !args[OPT_NOINFO] )
  675.                         Printf("# %ld %s found.\n",
  676.                                matches,
  677.                                ((matches == 1) ? "match" : "matches"));
  678.                 }
  679.                 else
  680.                 {
  681.                     if( !args[OPT_NOINFO] )
  682.                         Printf("# No matches\n");
  683.                 }
  684.                 
  685.                 if( !args[OPT_NOINFO] )
  686.                     Printf("# " VERS " (" DATE ")\n"
  687.                            "# Copyright (c)Lee Kindness, 2:259/15.46\n");
  688.                 GL_CloseNL(nl);
  689.             }
  690.             FreeArgs(rda);
  691.         } else
  692.             PrintFault(IoErr(), "# " PROGNAME);
  693.         CloseLibrary(GotchaLibBase);
  694.     }
  695.     return ret;
  696. }
  697.